package com.xintoucloud.springbootguide.model;

import java.util.List;

/**
 * 统一响应格式
 * @param <M>
 */
public class ResponseResult<M> {
    private int code;
    private String msg;
    private long count;
    private List<M> data;

    public static ResponseResult success(){
        ResponseResult result = new ResponseResult();
        result.setCode(0);
        result.setMsg("success");
        return result;
    }

    public static ResponseResult success(List data){
        ResponseResult result = new ResponseResult();
        result.setCode(0);
        result.setMsg("success");
        result.setData(data);
        return result;
    }

    public static ResponseResult error(List data){
        ResponseResult result = new ResponseResult();
        result.setCode(1);
        result.setMsg("error");
        return result;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public long getCount() {
        return count;
    }

    public void setCount(long count) {
        this.count = count;
    }

    public List<M> getData() {
        return data;
    }

    public void setData(List<M> data) {
        this.data = data;
    }



}
